import { createStore, compose, combineReducers, applyMiddleware } from 'redux';
import dataInfo from './reducers/geteducationinfo'
import slideShow from './reducers/getslideshow'
import selectValue from './reducers/selectreducer'
import pageTotalCount from './reducers/getecucationpage'
import configClass from './reducers/getconfigclass'
import education from './reducers/getconfigeducation'
import identity from './reducers/getconfigidentity'
import mode from './reducers/getconfigmode'
import role from './reducers/getconfigrole'
import subject from './reducers/getconfigsubject'
import sex from './reducers/getconfigsex'
let rootReducer = combineReducers({
    dataInfo,
    slideShow,
    selectValue,
    pageTotalCount,
    configClass,
    education,
    identity,
    mode,
    role,
    subject,
    sex
})

function logger({ getState }) {
    return (next) => (action) => {
        console.log('will dispatch', action)
        // 调用 middleware 链中下一个 middleware 的 dispatch。
        let returnValue = next(action)
        console.log('state after dispatch', getState())
        // 一般会是 action 本身，除非
        // 后面的 middleware 修改了它。
        return returnValue
    }
}
const thunk = ({ dispatch, getState }) => (next) => (action) => {
    if (typeof action === 'function') {
        return action(dispatch, getState);
    }
    return next(action);
};

const store = createStore(
    rootReducer,
    compose(
        applyMiddleware(thunk)
    )
);

export default store;